package com.yanyeori.framework.security.constant;

import com.yanyeori.framework.core.constant.BaseConstant;

/**
 * 常量
 *
 * @author chenkuan 2020/11/20
 */
public interface SecurityConst {
    //security包名
    String PACKAGE_NAME = "com.yanyeori.framework.security";

    //Header中的认证token
    String AUTHORIZATION = "Authorization";
    //Header中的请求时间戳属性
    String AUTH_TIMESTAMP = BaseConstant.HEADER_PRE + "auth-timestamp";
    //Header中的签名属性
    String AUTH_SIGN = BaseConstant.HEADER_PRE + "auth-sign";

    //Header中的访问渠道属性
    String HEADER_CHANNEL = BaseConstant.HEADER_PRE + "channel";

    //请求验证失败信息存储key
    String ERR_MSG_KEY = "securityRequestErrMsg";

    //Bearer前缀 --> Authorization: Bearer token
    String AUTH_BEARER_PRE = "Bearer ";
    //Basic前缀 --> Authorization: Basic token
    String AUTH_BASIC_PRE = "Basic ";

    //sso需要匿名访问的api
    String[] HTTP_ANON_API = {
            "/error/**",
            "/sso/login",
            "/sso/sign",
            "/sso/refresh"
    };

    //匿名访问的静态资源
    String[] WEB_ANON_API = {};

    //Swagger匿名访问的静态资源
    String[] WEB_ANON_API_SWAGGER = {
            "/swagger-resources/**",
            "/webjars/**",
            "/v2/api-docs",
            "/v3/api-docs",
            "/favicon.ico"
    };

    //redis保存user登录信息前缀
    String REDIS_TOKEN_KEY = "sso:token:{}";
    //redis保存user在线信息前缀
    String REDIS_ONLINE_KEY = "sso:online:{}:{}";

    //匿名登录凭证
    String ANONYMOUS_PRINCIPAL = "anonymousUser";

    //匿名登录ROLE
    String ROLE_ANONYMOUS = "ROLE_ANONYMOUS";

    //token默认有效时间（60分钟）
    long TOKEN_DEFAULT_EXPIRATION = 60;
}
